export function floatDecimal(val: number, count: number) {
	return Math.ceil(val * 10 ** count) / 10 ** count;
}

export function makePercentage(val: number) {
	return floatDecimal(val * 100, 2) + "%";
}

export function parseString(str: number | string) {
	if (typeof str === "string") {
		return parseFloat(str);
	} else {
		return str;
	}
}

export function parseToDot5(val: number) {
	const floor = Math.floor(val);
	const offset = val - floor;

	if (offset < 0.25) {
		return floor;
	} else if (offset > 0.75) {
		return floor + 1;
	} else {
		return floor + 0.5;
	}
}
